local skill = fk.CreateSkill {
  name = "lvshi__spear_skill&",
  attached_equip = "spear",
}

skill:addEffect(fk.TargetSpecified, {
  can_trigger = function(self, event, target, player, data)
    return target == player and player:hasSkill(skill.name) and data.card.trueName == "slash"
    and data.card.skillName == "spear"
  end,
  on_cost = Util.TrueFunc,
  on_use = function(self, event, target, player, data)
    data.fixedResponseTimes = data.fixedResponseTimes or 1
    local n = #table.filter(player.room:getSubcardsByRule(data.card), function (id)
      return Fk:getCardById(id).trueName == "slash"
    end)
    data:setResponseTimes(data.fixedResponseTimes + n, data.to)
    player.room:broadcastPlaySound("./packages/standard_cards/audio/card/spear")
    player.room:setEmotion(player, "./packages/standard_cards/image/anim/spear")
  end,
})

skill:addEffect("viewas", {
  prompt = "#lvshi__spear_skill&",
  pattern = "slash",
  handly_pile = true,
  card_filter = function(self, player, to_select, selected)
    return #selected < 2 and table.contains(player:getHandlyIds(), to_select)
  end,
  view_as = function(self, player, cards)
    if #cards ~= 2 then return nil end
    local c = Fk:cloneCard("slash")
    c.skillName = "spear"
    c:addSubcards(cards)
    return c
  end,
})



return skill